package com.liyawen.web;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;


public class LoginServlet extends HttpServlet
{

	private static final long serialVersionUID = 1L;

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException
	{
		String name = request.getParameter("name");
		HttpSession session = request.getSession();
		session.setAttribute("name", name);
		
		ServletContext application = getServletContext();
		
		List<String> nameList = (List<String>)application.getAttribute("nameList");
		
		if(nameList == null)
		{
			nameList = new ArrayList<String>();
		}
		nameList.add(name);
		application.setAttribute("nameList", nameList);
		response.sendRedirect("tojsp.jspx?_m=main");
	}

}
